﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

/// <summary>
/// 聊天气泡
/// </summary>
public class ChatBubble : MonoBehaviour
{
    [SerializeField] private Text ChatMsg;

    private void Update()
    {
        transform.rotation = Camera.main.transform.rotation;
    }

    public void ShowChat(string msg)
    {
        ChatMsg.text = msg;
        StartCoroutine(AutoDelete());
    }

    private IEnumerator AutoDelete()
    {
        yield return new WaitForSeconds(5f);                        //5s没有新信息气泡消失
        Destroy(gameObject);
    }
}
